/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rg1schoolclassdemo;

import java.util.ArrayList;
import java.util.Collections;

/**
 *
 * @author apple
 */
public class SchoolClass extends ArrayList<Student>{
    private String name;
    

    public SchoolClass() {
        
    }

    public SchoolClass(String name) {
        this.name = name;
        
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    
    
   
    
    
    
    public Student getbyNum(int num)
    {
        for(Student stu:this)   //foreach
        {
            if(stu.getNum()==num)
            {
                return stu;
            }
        }
        return null;
    }
    
    public void show()
    {
        for(Student stu:this)
        {
            stu.show();
        }
    }
    
    public void sortByNum()
    {
        //CompareByNum compareByNum=new CompareByNum();
        Collections.sort(this, new CompareByNum());
    }
    
    public void sortByJava()
    {
        Collections.sort(this, new CompareByJava());
    }
    
}
